<?php
namespace app\common\model;
use think\Model;
use think\Db;
/**
 * 学科类目
 */
class Account extends Model
{
    
    
    protected static function init()
    {
        Account::event('after_insert', function ($account) {
           $account->account = $account['id'] < 1000 ? 'svp'.sprintf("%04d",  $account->id):'svp'.$account->id;
           $account->save();
        });
    }

    public function getWorksAttr($value){
        if(empty($value)) return [];
        return json_decode($value,true);
    }

    public function setWorksAttr($value){
        if(!empty($value)) return json_encode($value);
    }
}